import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";

var _dec, _dec2, _dec3, _dec4, _class, _class2;

import React from 'react';
import { connect } from 'dva';
import { Bind } from 'lodash-decorators';
import notification from 'utils/notification';
import Designer from "../../designer";
var PageDetail = (_dec = connect(function (_ref) {
  var loading = _ref.loading,
      uiPage = _ref.uiPage;
  return {
    fetching: loading.effects['uiPage/fetchDetail'],
    saving: loading.effects['uiPage/detailUpdate'],
    uiPage: uiPage
  };
}), _dec2 = Bind(), _dec3 = Bind(), _dec4 = Bind(), _dec(_class = (_class2 = /*#__PURE__*/function (_React$Component) {
  _inherits(PageDetail, _React$Component);

  var _super = _createSuper(PageDetail);

  function PageDetail() {
    _classCallCheck(this, PageDetail);

    return _super.apply(this, arguments);
  }

  _createClass(PageDetail, [{
    key: "render",
    value: function render() {
      return /*#__PURE__*/React.createElement(Designer, Object.assign({}, this.props, {
        onSave: this.handleDesignerSave,
        getPageDetail: this.getPageDetail,
        bankPath: "/cpfm/ui/page/list"
      }));
    }
    /**
     * 获取当前编辑的页面编码
     */

  }, {
    key: "getPageCode",
    value: function getPageCode() {
      var pageCode = this.props.match.params.pageCode;
      return pageCode;
    }
  }, {
    key: "getPageDetail",
    value: function getPageDetail() {
      var dispatch = this.props.dispatch;
      var pageCode = this.getPageCode();
      return dispatch({
        type: 'uiPage/fetchDetail',
        payload: pageCode
      });
    }
  }, {
    key: "handleDesignerSave",
    value: function handleDesignerSave(saveConfig) {
      var dispatch = this.props.dispatch; // console.debug(JSON.stringify(saveConfig, 0, 2));
      // 需要保存

      return dispatch({
        type: 'uiPage/detailUpdate',
        payload: saveConfig
      }).then(function (res) {
        if (res) {
          // 保存成功
          notification.success();
        }

        return res;
      });
    }
  }]);

  return PageDetail;
}(React.Component), (_applyDecoratedDescriptor(_class2.prototype, "getPageCode", [_dec2], Object.getOwnPropertyDescriptor(_class2.prototype, "getPageCode"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "getPageDetail", [_dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "getPageDetail"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleDesignerSave", [_dec4], Object.getOwnPropertyDescriptor(_class2.prototype, "handleDesignerSave"), _class2.prototype)), _class2)) || _class);
export { PageDetail as default };